﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Linq.Expressions;
using Newtonsoft.Json.Linq;
using WebGrease.Css.Extensions;

using CanDoo;
using CanDoo.Core;
using CanDoo.Data;
using CanDoo.Web;
using CanDoo.FineUI;
using CanDoo.Extensions;
using CanDoo.Oil.Core.Models;
using CanDoo.Oil.Core.Contracts;
using CanDoo.Admin.Core.Contracts;
using CanDoo.Core.Data;
using FineUIPro;


namespace CanDoo.Oil.WebApp.storeSerialNumTemp
{
    public partial class InBuyBack : ListPageBase<ISerialNumTempContract, SerialNumTemp>
    {
        public IInStoreTypeContract InStoreTypeContract { get; set; }
        public IWarehouseContract WarehouseContract { get; set; }
        public IProductContract ProductContract { get; set; }

        public long WarehouseId = Web.Request.QueryString("WareHouseId").ToLong();
        public long EntityId = Web.Request.QueryString("EntityId").ToLong();
        public long ProductId = Web.Request.QueryString("ProductId").ToLong();
        #region 方法
        protected override void InitGrid()
        {
            Selector = p => new
            {
                p.InStoreType,
                p.InStoreTypeId,
                p.InStoreId,
                p.Warehouse,
                p.WarehouseId,
                p.Product,
                p.ProductId,
                p.SerialNumber,
                p.BirthDay,
                p.Batch,
                p.OverdueDay,
                p.Id,
                p.Name
            };
            base.InitGrid();
        }

        protected override void Search()
        {
            var key = SearchKey.GetValue();
            if (string.IsNullOrEmpty(key) == false)
            {
                Filter = Filter.And(p => p.SerialNumber.Contains(key));
            }
            Filter = Filter.And(p => p.WarehouseId == WarehouseId);
            Filter = Filter.And(p => p.ProductId == ProductId);
            Filter = Filter.And(p => p.InBuyBackId == EntityId);
        }

        protected override void PagePowerCheck()
        {
            base.PagePowerCheck();
            this.EnableAdd = false;
            this.EnableEdit = false;
        }

        protected override void SetControlInPage()
        {
            base.SetControlInPage();
        }
        #endregion

        #region 事件
        #region Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitGrid();
            }
        }
        #endregion

        #endregion 事件

    }
}
